<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>SimplerDateFormat | 下水道的包工头博客</title>
    <meta name="description" content="SimplerDateFormat">
    <link rel="icon" href="/sewerganger-blog/images/45007226.jpg">
  <link rel="manifest" href="/sewerganger-blog/manifest.json">
  <link rel="apple-touch-icon" href="/sewerganger-blog/images/45007226.jpg">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;">
    
    <link rel="preload" href="/sewerganger-blog/assets/css/0.styles.24e8e11a.css" as="style"><link rel="preload" href="/sewerganger-blog/assets/js/app.63bbb3d6.js" as="script"><link rel="preload" href="/sewerganger-blog/assets/js/2.130cf600.js" as="script"><link rel="preload" href="/sewerganger-blog/assets/js/17.1984db6e.js" as="script"><link rel="prefetch" href="/sewerganger-blog/assets/js/10.1ee9a4b2.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/11.0747cd60.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/12.175b5f6f.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/13.0a1aeebe.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/14.46608ec8.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/15.0f45f7ae.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/16.92fda98f.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/18.44dc0a8e.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/19.cbd49624.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/20.834fbdab.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/3.f6e049cc.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/4.649e3fd0.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/5.a535dbc2.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/6.dc8df762.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/7.bd3889bb.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/8.19dd839a.js"><link rel="prefetch" href="/sewerganger-blog/assets/js/9.37f814da.js">
    <link rel="stylesheet" href="/sewerganger-blog/assets/css/0.styles.24e8e11a.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/sewerganger-blog/" class="home-link router-link-active"><!----> <span class="site-name">下水道的包工头博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/sewerganger-blog/" class="nav-link">主页</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">文章</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/front/index.html" class="nav-link">前端</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/back/index.html" class="nav-link">后端</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/hole/index.html" class="nav-link">各种坑</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/win-linux/index.html" class="nav-link">win-linux</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/wheel/index.html" class="nav-link">造轮子</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/others/index.html" class="nav-link">其他</a></li></ul></div></div><div class="nav-item"><a href="/sewerganger-blog/about/index.html" class="nav-link">博主</a></div><div class="nav-item"><a href="https://github.com/sewerganger" target="_blank" rel="noopener noreferrer" class="nav-link external">
  github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://gitee.com/sewerganger/events" target="_blank" rel="noopener noreferrer" class="nav-link external">
  githee
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/sewerganger-blog/" class="nav-link">主页</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">文章</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/front/index.html" class="nav-link">前端</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/back/index.html" class="nav-link">后端</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/hole/index.html" class="nav-link">各种坑</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/win-linux/index.html" class="nav-link">win-linux</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/wheel/index.html" class="nav-link">造轮子</a></li><li class="dropdown-item"><!----> <a href="/sewerganger-blog/article/others/index.html" class="nav-link">其他</a></li></ul></div></div><div class="nav-item"><a href="/sewerganger-blog/about/index.html" class="nav-link">博主</a></div><div class="nav-item"><a href="https://github.com/sewerganger" target="_blank" rel="noopener noreferrer" class="nav-link external">
  github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://gitee.com/sewerganger/events" target="_blank" rel="noopener noreferrer" class="nav-link external">
  githee
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>前端包工头</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>后端包工头</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>包工头掉过的坑</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>包工头 love windows&amp;linux</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>包工头造轮子</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/sewerganger-blog/article/wheel/wheel0.html" class="active sidebar-link">SimplerDateFormat</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/sewerganger-blog/article/wheel/wheel0.html#_1-api" class="sidebar-link">1. Api</a></li><li class="sidebar-sub-header"><a href="/sewerganger-blog/article/wheel/wheel0.html#_2-usage" class="sidebar-link">2. Usage</a></li><li class="sidebar-sub-header"><a href="/sewerganger-blog/article/wheel/wheel0.html#english" class="sidebar-link">english</a></li><li class="sidebar-sub-header"><a href="/sewerganger-blog/article/wheel/wheel0.html#chinese" class="sidebar-link">chinese</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="simplerdateformat"><a href="#simplerdateformat" aria-hidden="true" class="header-anchor">#</a> SimplerDateFormat</h1> <p><strong>This package likes java's SimpeDateFormat. But it is simpler!</strong></p> <h2 id="_1-api"><a href="#_1-api" aria-hidden="true" class="header-anchor">#</a> 1. <strong>Api</strong></h2> <p>format(date: Date); // format time you want
zone(number); // setZoneTime and format</p> <h2 id="_2-usage"><a href="#_2-usage" aria-hidden="true" class="header-anchor">#</a> 2. <strong>Usage</strong></h2> <h2 id="english"><a href="#english" aria-hidden="true" class="header-anchor">#</a> english</h2> <p>Capital letters for date and lowercase letters for time, letters are random,
Using space separation, The order in which you enter is the order in which you output. Use special symbols(except ~) to represent what day of the week you output.
add <code>~</code> before sentence to reverse output;</p> <h2 id="chinese"><a href="#chinese" aria-hidden="true" class="header-anchor">#</a> chinese</h2> <p>日期用大写字母，时间用小写字母，字母是随机的，</p> <p>使用空格分隔，输入的顺序是输出的顺序。使用特殊符号（除~）表示一周中输出的日期。</p> <p>在句子前加<code>~</code>可反转输出；</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">const</span> SimplerDateFormat <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&quot;simpler-date-format&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> weekday <span class="token operator">=</span> <span class="token punctuation">[</span>
  <span class="token string">&quot;Monday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Tuesday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Wednesday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Thursday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Friday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Saturday&quot;</span><span class="token punctuation">,</span>
  <span class="token string">&quot;Sunday&quot;</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> sd <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimplerDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;Y/M/D h:m:d&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
sd<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//2019/04/23 22:36:44</span>

<span class="token keyword">var</span> sd <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimplerDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;Y$M$D h:m:d @&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
sd<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//2019$04$23 22:36:44 2</span>

<span class="token keyword">var</span> sd <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimplerDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;h:m:d Y/M/D&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
sd<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//22:36:44 2019/04/23</span>

<span class="token keyword">var</span> sd <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimplerDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;@ h:m:d ~Y/M/D&quot;</span><span class="token punctuation">,</span> week<span class="token punctuation">)</span><span class="token punctuation">;</span>
sd<span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// Tuesday 22:36:44 04/23/2019</span>

<span class="token keyword">var</span> sd <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimplerDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;h:m:d ~Y/M/D&quot;</span><span class="token punctuation">,</span> week<span class="token punctuation">)</span><span class="token punctuation">;</span>
sd<span class="token punctuation">.</span><span class="token function">zone</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//22:36:44 04/23/2019 Tuesday Beijing time</span>
</code></pre></div><ol start="3"><li>many functions are not added, coming soon</li></ol> <p>if you like, please star on github❤</p></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">7/11/2019, 10:30:58 AM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/sewerganger-blog/article/winLinux/winLinux0.html" class="prev">
          /article/winLinux/winLinux0.html
        </a></span> <!----></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/sewerganger-blog/assets/js/app.63bbb3d6.js" defer></script><script src="/sewerganger-blog/assets/js/2.130cf600.js" defer></script><script src="/sewerganger-blog/assets/js/17.1984db6e.js" defer></script>
  </body>
</html>
